{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #To Lower Case"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #string"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #字符串"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: toLowerCase"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #转换成小写字母"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>给你一个字符串 <code>s</code> ，将该字符串中的大写字母转换成相同的小写字母，返回新的字符串。</p>\n",
    "\n",
    "<p> </p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>s = \"Hello\"\n",
    "<strong>输出：</strong>\"hello\"\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>s = \"here\"\n",
    "<strong>输出：</strong>\"here\"\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 3：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>s = \"LOVELY\"\n",
    "<strong>输出：</strong>\"lovely\"\n",
    "</pre>\n",
    "\n",
    "<p> </p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>1 <= s.length <= 100</code></li>\n",
    "\t<li><code>s</code> 由 ASCII 字符集中的可打印字符组成</li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [to-lower-case](https://leetcode.cn/problems/to-lower-case/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [to-lower-case](https://leetcode.cn/problems/to-lower-case/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['\"Hello\"', '\"here\"', '\"LOVELY\"']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "      return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, str: str) -> str:\n",
    "        #return str.lower()\n",
    "        s=[]\n",
    "        for i in str:\n",
    "            if 65<=ord(i)<=90:\n",
    "                s.append(chr(ord(i)+32))\n",
    "            else:\n",
    "                s.append(i)\n",
    "        return ''.join(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        #return s.lower()\n",
    "        n=[]\n",
    "        for i in s:\n",
    "            if ord(i)<91 and ord(i)>64:\n",
    "                i=chr(ord(i)+32)\n",
    "                n.append(i)\n",
    "            else:n.append(i)\n",
    "        return ''.join(n)\n",
    "                "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        tmp = []\n",
    "        for x in s:\n",
    "            if 65 <= ord(x) <= 90:\n",
    "                x = chr(32+ord(x))\n",
    "            tmp.append(x)\n",
    "        return \"\".join(tmp)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()\n",
    "        \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        res = ''\n",
    "        for letter in s:\n",
    "            res = res + ''.join(letter.lower())\n",
    "        return res \n",
    "        # return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        ## Method 1 try to lower character with method of string.upper()\n",
    "        # return s.lower()\n",
    "\n",
    "        # Method 2 try to lower character with ASCII code\n",
    "        return \"\".join(chr(asc | 32) if 65 <= (asc := ord(ch)) <= 90 else ch for ch in s)\n",
    "        # 补充知识\n",
    "        # 1.大写字母对应ASCII码的范围是[65,90], 小写字母对应ASCII码的范围是[97,122] 对应字母相差32\n",
    "        # 2.python 中 ord()方法与chr()方法分别可以将字符转为对应的Unuque ASCII码 和将ASCII码转化为对应字符\n",
    "        # 3.在对字符进行加减运算时应当使用 &、｜、^ 分别是与、或、异或的计算结果\n",
    "        # 4.join()方法是字符串对象的内置方法，可用于字符串之间的连接\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        result =\"\"\n",
    "        b=None\n",
    "        for i in s:\n",
    "            if 'A' <= i <= 'Z':\n",
    "                i=chr(ord(i)+32)\n",
    "                \n",
    "            result+=i\n",
    "        print(result)\n",
    "        return result\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "      s1 = ''\n",
    "      for i in range(len(s)):\n",
    "        if 65 <= ord(s[i]) <= 90:\n",
    "          s1 = s1 + chr(int(ord(s[i]) + 32))\n",
    "        else:\n",
    "          s1 = s1 + s[i]\n",
    "      return s1\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        # return s.lower()\n",
    "        # keyMap = defaultdict(str)\n",
    "        keyMap = {'A': 'a', 'B': 'b', 'C': 'c', 'D': 'd', 'E': 'e', 'F': 'f', 'G': 'g', 'H': 'h', 'I': 'i', 'J': 'j',\n",
    "                  'K': 'k', 'L': 'l', 'M': 'm', 'N': 'n', 'O': 'o', 'P': 'p', 'Q': 'q', 'R': 'r', 'S': 's', 'T': 't',\n",
    "                  'U': 'u', 'V': 'v', 'W': 'w', 'X': 'x', 'Y': 'y', 'Z': 'z'}\n",
    "        # print(keyMap)\n",
    "        sl = list(s)\n",
    "        for i in range(len(sl)):\n",
    "            # if keyMap[sl[i]] != '':\n",
    "            #     sl[i] = keyMap[sl[i]]\n",
    "            if keyMap.get(sl[i]):\n",
    "                sl[i] = keyMap[sl[i]]\n",
    "        return ''.join(sl)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        new_str = ''\n",
    "        for i in range(len(s)):\n",
    "            if ord(s[i]) <= ord('Z') and ord(s[i]) >= ord('A'):\n",
    "                new_str += chr(ord(s[i]) + 32)\n",
    "            else:\n",
    "                new_str += s[i]\n",
    "        return new_str"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return \"\".join(chr(asc | 32) if 65 <= (asc := ord(ch)) <= 90 else ch for ch in s)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "      str=\"\"\n",
    "      for ch in s:\n",
    "        if(65<=(asc:=ord(ch))<=90): #ord返回ASCII值 chr返回ASCII符\n",
    "          str=str+(chr(asc | 32))\n",
    "        else:\n",
    "          str=str+ch\n",
    "      return str"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "\tdef toLowerCase(self, str):\n",
    "\t\treturn str.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return \"\".join(chr(asc | 32) if 65 <= (asc := ord(ch)) <= 90 else ch for ch in s)\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        n = len(s)\n",
    "        i = 0\n",
    "        t = ''\n",
    "        for i in range(n):\n",
    "            tag = ord(s[i])\n",
    "            if 65 <= tag <= 90:\n",
    "                t += chr(tag + 32)\n",
    "            else:\n",
    "                t += chr(tag)\n",
    "        return t\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        s = s.lower()\n",
    "        return s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        ans = list(s)\n",
    "        for i, c in enumerate(map(ord, ans)):\n",
    "            if ord('A') <= c <= ord('Z'):\n",
    "                ans[i] = chr(c + 32)\n",
    "        return ''.join(ans)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        result = \"\"\n",
    "        for char in s:\n",
    "            if 'A' <= char <= 'Z':\n",
    "                result += chr(ord(char) + 32)\n",
    "            else:\n",
    "                result += char\n",
    "        return result\n",
    "\n",
    "# 测试用例\n",
    "solution = Solution()\n",
    "test_case_1 = \"Hello\"\n",
    "test_case_2 = \"here\"\n",
    "test_case_3 = \"LOVELY\"\n",
    "\n",
    "result_1 = solution.toLowerCase(test_case_1)\n",
    "result_2 = solution.toLowerCase(test_case_2)\n",
    "result_3 = solution.toLowerCase(test_case_3)\n",
    "\n",
    "print(result_1)  # 输出：\"hello\"\n",
    "print(result_2)  # 输出：\"here\"\n",
    "print(result_3)  # 输出：\"lovely\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        str_r = ''\n",
    "        str_r = s.lower()\n",
    "        return str_r\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        n = ''\n",
    "        for i in s:\n",
    "            if 65 <= ord(i) <= 90:\n",
    "                i = chr(ord(i) + 32)\n",
    "            n += i\n",
    "        return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        s =s.lower()\n",
    "        return s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\r\n",
    "    def toLowerCase(self, s: str) -> str:\r\n",
    "        return s.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        return \"\".join(chr(asc | 32) if 65 <= (asc := ord(ch)) <= 90 else ch for ch in s)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def toLowerCase(self, s: str) -> str:\n",
    "        s1 = str()\n",
    "        for i in s:\n",
    "            if 64 <ord(i) < 91:\n",
    "                i = chr(ord(i) + 32)\n",
    "            s1 += i\n",
    "\n",
    "        return s1\n",
    "            \n",
    "          \n",
    "    "
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
